package com.fan.controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LoginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         //1.使用request获取请求参数
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        //2.校验用户名和密码
        if ("fjg".equals(username)&&"FJG314159".equals(password)){
            //登录成功
            response.getWriter().write("login  success");
        }else{
            response.getWriter().print("login fail");
        }
    }
}
